import http from "@/api";
import { Site, SiteDetail, AccStationer, AccDelivery, AccNeighborhood } from "@/api/interface/city/site";
// 驿站管理
// 列表
export const getSiteListAPI = (params: Site.Params) => {
  return http.get<Site.Row[]>("/manager/warehouse", params);
};
// 驿站详情
export const getSiteDetailAPI = (id: string) => {
  return http.get<SiteDetail.Data>("/manager/warehouse/" + id);
};
// 修改驿站时间
export const updateSiteTimeAPI = (data: SiteDetail.UpdateTime) => {
  return http.put("/manager/warehouse", data);
};
// 开通临时驿站
export const openTempSiteAPI = (data: SiteDetail.OpenSite) => {
  return http.post("/manager/warehouse/openTemporaryTakeover", data);
};
// 关闭临时驿站
export const closeTempSiteAPI = (data: { id: string; temporaryTakeover: number }) => {
  return http.post("/manager/warehouse/closeTemporaryTakeover", data);
};

// 站长关联列表
// 站长已选列表
export const getSiteSelectedListAPI = (params: { id: string }) => {
  return http.get<AccStationer.ElaryData>("/manager/warehouse/relateMasterInfo", params);
};
// 可选站长列表
export const getSiteMasterListAPI = (params: AccStationer.CanParams) => {
  return http.get<AccStationer.CanRow[]>("/manager/stationMaster/list", params);
};
// 关联站长
export const relateMasterAPI = (data: { id: string; userId: number }) => {
  return http.post("/manager/warehouse/relateMaster", data);
};
// 移除关联
export const removeMasterAPI = (data: { id: string }) => {
  return http.post("/manager/warehouse/unRelateMaster", data);
};

// 配送员关联列表
// 配送员已选列表
export const getDeliverySelectedListAPI = (params: { id: string }) => {
  return http.get<AccDelivery.ElData[]>("/manager/warehouse/relateDeliveryList", params);
};
// 可选配送员列表
export const getDeliveryListAPI = (params: AccDelivery.CanParams) => {
  return http.get<AccDelivery.CanRow[]>("/manager/deliveryman/optionalList", params);
};
// 关联配送员
export const relateDeliveryAPI = (data: { id: string; userId: number }) => {
  return http.post("/manager/warehouse/relateDelivery", data);
};
// 移除关联
export const removeDeliveryAPI = (data: { id: number }) => {
  return http.post("/manager/warehouse/unRelateDelivery", data);
};

// 小区关联
// 已关联小区列表
export const getCommunitySelectedListAPI = (params: { id: string }) => {
  return http.get<AccNeighborhood.ElData[]>("/manager/warehouse/relateNeighborhoodList", params);
};
// 可选小区列表
export const getCommunityListAPI = (params: AccNeighborhood.CanParams) => {
  return http.get<AccNeighborhood.CanRow[]>("/manager/neighborhood/list", params);
};
// 移除
export const removeCommunityAPI = (data: { id: number }) => {
  return http.post("/manager/warehouse/unRelateNeighborhood", data);
};
// 关联
export const relateCommunityAPI = (data: { id: string; neighborhoodId: number }) => {
  return http.post("/manager/warehouse/relateNeighborhood", data);
};
